package hnqigczy.zzptc.com.demomycharts;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;

import org.achartengine.ChartFactory;
import org.achartengine.renderer.DefaultRenderer;
import org.achartengine.renderer.SimpleSeriesRenderer;

/**
 * Created by zzsgz on 2018/10/7.
 */

public class PieChart extends AbstractDemoChart {
    @Override
    public String getName() {
        return "aaa";
    }

    @Override
    public String getDesc() {
        return "bbb";
    }

    @Override
    public Intent execute(Context context) {
        double[] values = new double[] { 12, 14, 11, 10, 19 };
        int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA, Color.YELLOW, Color.CYAN };
        DefaultRenderer renderer = buildCategoryRenderer(colors);
        renderer.setZoomButtonsVisible(true);
        renderer.setZoomEnabled(true);
        renderer.setChartTitle("各区人数图");
        renderer.setChartTitleTextSize(30);
        renderer.setDisplayValues(true);
        renderer.setShowLabels(true);
        SimpleSeriesRenderer r = renderer.getSeriesRendererAt(0);
        r.setGradientEnabled(true);
        r.setGradientStart(0, Color.BLUE);
        r.setGradientStop(0, Color.GREEN);
        r.setHighlighted(true);
        Intent intent = ChartFactory.getPieChartIntent(context,
                buildCategoryDataset("Project budget", values), renderer, "Budget");
        return intent;
    }
}
